home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 2257 / 2257.xpi / chrome / content / options.js < prev    next >
Text File  |  2009-12-29  |  7KB  |  170 lines

  1.  
  2. var com_smartlinkcorp_imtranslatorOptions = new Object();
  3.  
  4.  
  5.  var ImTranslator_Prefs = Components.classes["@mozilla.org/preferences-service;1"]
  6.                       .getService(Components.interfaces.nsIPrefService)
  7.                       .getBranch("imtranslator.");
  8.  
  9.  
  10. com_smartlinkcorp_imtranslatorOptions.imtranslator_initializeOptions = function () {
  11.     if (!ImTranslator_Prefs.prefHasUserValue("showBut")) ImTranslator_Prefs.setBoolPref("showBut",true);
  12.     this.showBut = document.getElementById("showBut");
  13.     this.showBut.checked = ImTranslator_Prefs.getBoolPref("showBut");
  14.  
  15.     com_smartlinkcorp_imtranslatorOptions.imtranslatorSelectorSet();
  16.  
  17.     com_smartlinkcorp_imtranslatorOptions.imtranslatorDirFrom();
  18.     com_smartlinkcorp_imtranslatorOptions.imtranslatorDirTo("dirParentTo");
  19.  
  20.     if (!ImTranslator_Prefs.prefHasUserValue("AutoDetect")) ImTranslator_Prefs.setBoolPref("AutoDetect",false);
  21.     this.AutoDetect = document.getElementById("AutoDetect");
  22.     this.AutoDetect.checked = ImTranslator_Prefs.getBoolPref("AutoDetect");
  23.  
  24.     if (!ImTranslator_Prefs.prefHasUserValue("AutoBack")) ImTranslator_Prefs.setBoolPref("AutoBack",false);
  25.     this.AutoBack = document.getElementById("AutoBack");
  26.     this.AutoBack.checked = ImTranslator_Prefs.getBoolPref("AutoBack");
  27.  
  28.     if (!ImTranslator_Prefs.prefHasUserValue("AutoSpell")) ImTranslator_Prefs.setBoolPref("AutoSpell",false);
  29.     this.AutoSpell = document.getElementById("AutoSpell");
  30.     this.AutoSpell.checked = ImTranslator_Prefs.getBoolPref("AutoSpell");
  31.  
  32.     if (!ImTranslator_Prefs.prefHasUserValue("AutoDecode")) ImTranslator_Prefs.setBoolPref("AutoDecode",false);
  33.     this.AutoDecode = document.getElementById("AutoDecode");
  34.     this.AutoDecode.checked = ImTranslator_Prefs.getBoolPref("AutoDecode");
  35.  
  36.     if (!ImTranslator_Prefs.prefHasUserValue("AutoTranslit")) ImTranslator_Prefs.setBoolPref("AutoTranslit",false);
  37.     this.AutoTranslit = document.getElementById("AutoTranslit");
  38.     this.AutoTranslit.checked = ImTranslator_Prefs.getBoolPref("AutoTranslit");
  39.  
  40.     if (!ImTranslator_Prefs.prefHasUserValue("GoogleOnly")) ImTranslator_Prefs.setBoolPref("GoogleOnly",false);
  41.     this.GoogleOnly = document.getElementById("GoogleOnly");
  42.     this.GoogleOnly.checked = ImTranslator_Prefs.getBoolPref("GoogleOnly");
  43.  
  44.     if (!ImTranslator_Prefs.prefHasUserValue("AutoDictionary")) ImTranslator_Prefs.setBoolPref("AutoDictionary",false);
  45.     this.AutoDictionary = document.getElementById("AutoDictionary");
  46.     this.AutoDictionary.checked = ImTranslator_Prefs.getBoolPref("AutoDictionary");
  47.  
  48. }
  49.  
  50. com_smartlinkcorp_imtranslatorOptions.imtranslator_saveOptions = function () {
  51.     this.showBut = document.getElementById("showBut").checked;
  52.     ImTranslator_Prefs.setBoolPref("showBut",this.showBut);
  53.  
  54.     this.locParent = document.getElementById("locParent").value;
  55.     ImTranslator_Prefs.setCharPref("locParent",this.locParent);
  56.  
  57.  
  58.     this.dirParentFrom = document.getElementById("dirParentFrom");
  59.     this.dirParentTo = document.getElementById("dirParentTo");
  60.     if(this.dirParentFrom.value == this.dirParentTo.value){
  61.         alert("Default (from/to) language direction cannot be the same!");
  62.         return false;
  63.     }else{
  64.         ImTranslator_Prefs.setCharPref("dirParentFrom",this.dirParentFrom.value);
  65.         ImTranslator_Prefs.setCharPref("dirParentTo",this.dirParentTo.value);
  66.     }
  67.  
  68.  
  69.     this.AutoDetect = document.getElementById("AutoDetect").checked;
  70.     ImTranslator_Prefs.setBoolPref("AutoDetect",this.AutoDetect);
  71.  
  72.     this.AutoBack = document.getElementById("AutoBack").checked;
  73.     ImTranslator_Prefs.setBoolPref("AutoBack",this.AutoBack);
  74.  
  75.     this.AutoSpell = document.getElementById("AutoSpell").checked;
  76.     ImTranslator_Prefs.setBoolPref("AutoSpell",this.AutoSpell);
  77.  
  78.     this.AutoDecode = document.getElementById("AutoDecode").checked;
  79.     ImTranslator_Prefs.setBoolPref("AutoDecode",this.AutoDecode);
  80.  
  81.     this.AutoTranslit = document.getElementById("AutoTranslit").checked;
  82.     ImTranslator_Prefs.setBoolPref("AutoTranslit",this.AutoTranslit);
  83.  
  84.     this.GoogleOnly = document.getElementById("GoogleOnly").checked;
  85.     ImTranslator_Prefs.setBoolPref("GoogleOnly",this.GoogleOnly);
  86.  
  87.     this.AutoDictionary = document.getElementById("AutoDictionary").checked;
  88.     ImTranslator_Prefs.setBoolPref("AutoDictionary",this.AutoDictionary);
  89.  
  90.     Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).savePrefFile(null);
  91. }
  92.  
  93. com_smartlinkcorp_imtranslatorOptions.imtranslatorHomePage = function ()
  94. {
  95.  
  96.     var url = "http://www.smartlinkcorp.com";
  97.     var windowService = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
  98.     var currentWindow = windowService.getMostRecentWindow("navigator:browser");
  99.  
  100.     if(currentWindow)
  101.     {
  102.         try {
  103.             currentWindow.delayedOpenTab(url);
  104.         } catch(e) {
  105.             currentWindow.loadURI(url);
  106.         }
  107.     }
  108.     else
  109.         window.open(url);
  110.  
  111. }
  112.  
  113.  
  114. com_smartlinkcorp_imtranslatorOptions.imtranslatorToolbarSet = function ()
  115. {
  116. if(document.getElementById("showBut").checked==true)
  117.     document.getElementById("ImTimg1").src="chrome://imtranslator/skin/ImTbuttonOff.png";
  118. else
  119.     document.getElementById("ImTimg1").src="chrome://imtranslator/skin/ImTbuttonOn.png";
  120. }
  121.  
  122.  
  123. com_smartlinkcorp_imtranslatorOptions.imtranslatorCheckBoxSet = function ()
  124. {
  125.     if (!ImTranslator_Prefs.prefHasUserValue("loc")) {
  126.         this.showLoc = document.getElementById("showBut");
  127.         this.showLoc.selected = ImTranslator_Prefs.getBoolPref("showBut");
  128.     }
  129. /*
  130.  var ImTob=document.getElementById("showBut");
  131.  com_smartlinkcorp_imtranslatorOptions.imtranslatorToolbarSet();
  132.  if(ImTob.checked==true) ImTob.checked=false;
  133.  else ImTob.checked=true;
  134. */
  135. }
  136.  
  137. com_smartlinkcorp_imtranslatorOptions.imtranslatorSelectorSet = function ()
  138. {
  139.     if (!ImTranslator_Prefs.getCharPref("locParent")) ImTranslator_Prefs.setCharPref("locParent","en");
  140.     this.locParent = document.getElementById("locParent");
  141.  
  142.     for(var i=0;i<this.locParent.itemCount;i++) {
  143.        if(this.locParent.getItemAtIndex(i).value == ImTranslator_Prefs.getCharPref("locParent")) {this.locParent.selectedIndex=i;}
  144.     }
  145. }
  146.  
  147. com_smartlinkcorp_imtranslatorOptions.imtranslatorDirFrom = function ()
  148. {
  149.     if (!ImTranslator_Prefs.getCharPref("dirParentFrom")) ImTranslator_Prefs.setCharPref("dirParentFrom","en");
  150.     this.dirParentFrom = document.getElementById("dirParentFrom");
  151.  
  152.     for(var i=0;i<this.dirParentFrom.itemCount;i++) {
  153.        if(this.dirParentFrom.getItemAtIndex(i).value == ImTranslator_Prefs.getCharPref("dirParentFrom")) {this.dirParentFrom.selectedIndex=i;}
  154.     }
  155. }
  156.  
  157. com_smartlinkcorp_imtranslatorOptions.imtranslatorDirTo = function ()
  158. {
  159.     if (!ImTranslator_Prefs.getCharPref("dirParentTo")) ImTranslator_Prefs.setCharPref("dirParentTo","en");
  160.     this.dirParentTo = document.getElementById("dirParentTo");
  161.  
  162.     for(var i=0;i<this.dirParentTo.itemCount;i++) {
  163.        if(this.dirParentTo.getItemAtIndex(i).value == ImTranslator_Prefs.getCharPref("dirParentTo")) {this.dirParentTo.selectedIndex=i;}
  164.     }
  165. }
  166.  
  167.  
  168.  
  169.  
  170.